#include <bits/stdc++.h>
using namespace std;
const int N = 4000 + 10;
vector<int> adj[N];
struct Node {
  int w, b;
} node[N];
char color[N];
int n;

void dfs(int rt) {
  color[rt] == 'B' ? node[rt].b++ : node[rt].w++;
  for (auto v : adj[rt]) {
    dfs(v);
    node[rt].w += node[v].w;
    node[rt].b += node[v].b;
  }
}
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    memset(node, 0, sizeof(node));
    cin >> n;
    int root = 1;
    for (int i = 1; i <= n; ++i) adj[i].clear();
    for (int i = 2; i <= n; ++i) {
      int x;
      cin >> x;
      adj[x].push_back(i);
    }
    cin >> color + 1;
    dfs(root);

    int good = 0;
    for (int i = 1; i <= n; ++i) {
      if (node[i].b == node[i].w) good++;
    }
    cout << good << endl;
  }
}
